package com.apes.fico.finance.model.statements;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.plugin.soe.annotations.State;
import com.apes.framework.plugin.soe.annotations.States;
import com.apes.fico.masterdata.gl.model.AccountingChart;
import com.apes.fico.masterdata.gl.model.AccountingModel;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @program: apestech
 * @description: 资产负债表模板定义
 * @author: Chengxm
 * @create: 2019-01-21 15:27
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = BalanceSheetFormula.CONST_TABLE_NAME)
public class BalanceSheetFormula extends BaseModel {
    public final static String CONST_TABLE_NAME = "gl_balance_sheet_formula";
    @Id
    @Column(name = "id", nullable = false, length = 32)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "资产负债表", padding = 8)
    @Comment("编号")
    private String id;

    @ManyToOne()
    @JoinColumn(name = "acc_chart_id", referencedColumnName = "id")
    @Comment("科目")
    private AccountingChart accountingChart;

    @Column(name = "acc_code")
    @Comment("科目代码")
    private String code;

    @Column(name = "operator", length = 1)
    @Comment("运算符号")
    @States(name = "运算符号", values = {
            @State(id = AccountingModel.PLUS, name = "+"),
            @State(id = AccountingModel.MINUS, name = "-")})
    private String orientation;

    @NotNull
    @Column(name = "seq")
    @Comment("行次")
    private String Seq;
}
